package com.gg.user.gguser.service.impl;

import com.gg.user.gguser.dao.GgUserDaoMapper;
import com.gg.user.gguser.dataobject.GgUserDataobject;
import com.gg.user.gguser.service.GgUserGetAllService;
import com.gg.vo.return_format;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author yangxinlei
 * @date 2020/5/20
 */
@Service
public class GgUserGetAllServiceImpl implements GgUserGetAllService {

    @Autowired
    private GgUserDaoMapper ggUserDaoMapper;

    @Override
    public Map getUserStaff(Integer ggGrade, String getUserId, Integer page, Integer pageNumber) {
        if( ggGrade == 1){
            Integer getUserSelectCount = ggUserDaoMapper.getRootUserSelectCountGrade(null);
            List<GgUserDataobject> userList = ggUserDaoMapper.getRootUserSelectCount((page - 1) * pageNumber, pageNumber,null);
            return return_format.return_format_data_map(page, (int) Math.ceil(getUserSelectCount/pageNumber),pageNumber,getUserSelectCount,userList);
        }else if(ggGrade==2){
            // 查询出全部客户
            Integer getUserSelectCount = ggUserDaoMapper.getRootUserSelectCountGrade(3);
            List<GgUserDataobject> userList = ggUserDaoMapper.getRootUserSelectCount((page - 1) * pageNumber, pageNumber,3);
            return return_format.return_format_data_map(page, (int) Math.ceil(getUserSelectCount/pageNumber),pageNumber,getUserSelectCount,userList);
        }else if(ggGrade==3){
            // 公司身份查询出自己下面的
            Integer getUserSelectCount = ggUserDaoMapper.getGgBinDing(getUserId);
            List<GgUserDataobject> userList = ggUserDaoMapper.getGgBinDingSelectCount((page - 1) * pageNumber, pageNumber,getUserId);
            return return_format.return_format_data_map(page, (int) Math.ceil(getUserSelectCount/pageNumber),pageNumber,getUserSelectCount,userList);
        }else if(ggGrade==4 || ggGrade==5){
            // 身份有点太低没有模块权限
            return return_format.return_format_data_map(-1, 0,0,null,null);
        }else {
            return return_format.return_format_data_map(-1, 0,0,null,null);
        }
    }


}
